package Spring5.第二章.demo2_7_策略模式.卖课;

import java.util.HashMap;
import java.util.Map;

public class PromotionStrategyFactory {
    private static Map<String, PromotionStrategy> PROMOTION_STRAGETY_MAP = new HashMap<>();

    static {
        PROMOTION_STRAGETY_MAP.put(PromotionKey.COUPON, new CouponStrategy());
        PROMOTION_STRAGETY_MAP.put(PromotionKey.CASHBACK, new CashbackStrategy());
        PROMOTION_STRAGETY_MAP.put(PromotionKey.GROUPBUY, new GroupbuyStrategy());
        PROMOTION_STRAGETY_MAP.put(PromotionKey.NOPROMOTION, new EmptyStrategy());
    }

    private static final PromotionStrategy  MON_PROMOTION = new EmptyStrategy();

    private PromotionStrategyFactory() {}

    public static PromotionStrategy getPromotionStrategy(String promotionKey) {
        PromotionStrategy promotionStrategy = PROMOTION_STRAGETY_MAP.get(promotionKey);
        return promotionStrategy;
    }
}
